package com.tjetc.service.impl;

import com.tjetc.dao.ProfitDao;
import com.tjetc.dao.impl.ProfitDaoImpl;
import com.tjetc.domain.Profit;
import com.tjetc.service.ProfitService;

import java.sql.SQLException;
import java.util.List;

public class ProfitServiceImpl implements ProfitService {
    private ProfitDao profitDao=new ProfitDaoImpl();
    @Override
    public List<Profit> list() {
        try {
            return profitDao.list();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<Profit> listbydate(String startDate, String endDate) {
        try {
            return profitDao.listbydate(startDate,endDate);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Profit findByDate(String date) {
        try {
            return profitDao.findByDate(date);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public boolean addProfit(Profit profit) {
        try {
            profitDao.addProfit(profit);
            return true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean updateProfit(Profit profit){
        try {
            profitDao.updateProfit(profit);
            return true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
}
